import request from '../utils/request';

export function login(userInfo) {
  console.log('user info: ', userInfo);
  return request({
    method: 'post',
    url: '/v1/auth/login',
    data: userInfo
  });
}
// 获取消息列表
export const getMessList = (params, token) =>
  request({
    method: 'get',
    url: '/v1/message/selectModuleMsg',
    params: params,
    headers: {
      token
    }
  });

// 获取消息详情
export const getMessDetail = (params, token) =>
  request({
    method: 'get',
    url: '/v1/message/selectMessageList',
    params: params,
    headers: {
      token
    }
  });

export function logout() {
  return request({
    method: 'post',
    url: '/v1/auth/logout'
  });
}

export function fetchUserInfo(token) {
  return request({
    method: 'get',
    url: '/v1/auth/user',
    headers: {
      token
    }
  });
}

// get alarm type
export function fetchAlarmType(token, orgCode) {
  return request({
    method: 'get',
    url: `/v1/alarm/loadAlarmType/${orgCode}`,
    headers: {
      token
    }
  });
}

// 获取类型描述
export function fetchAlarmTypeDesc(token, typeId) {
  return request({
    method: 'get',
    url: `/v1/alarm/loadAlarmTypeDesc/${typeId}`,
    headers: {
      token
    }
  });
}

// 开始报警
export function startAlarm(token, record) {
  return request({
    method: 'post',
    url: '/v1/alarm/addAlarm',
    headers: {
      token
    },
    data: record
  });
}

export function getRecordList(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/policeMovement/policeMovementRecord/list',
    headers: {
      token
    }
  });
}

export function queryByDept(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/policeMovement/policeMovementRecord/queryByDept',
    headers: {
      token
    }
  });
}

export function queryByPoliceCode(token) {
  return request({
    method: 'get',
    url: '/v1/policeMovement/policeMovementRecord/queryByPoliceCode',
    headers: {
      token
    }
  });
}

export function queryByPoliceDept(token) {
  return request({
    method: 'get',
    url: '/v1/policeMovement/policeMovementRecord/queryByPoliceDept',
    headers: {
      token
    }
  });
}

export function addEduTalk(token, data) {
  return request({
    method: 'post',
    url: '/v1/educate/talk/add',
    headers: {
      token
    },
    params: {
      pfiFileName: data.pfiFileName,
      pfiFilePath: data.pfiFilePath,
      pfiFileType: data.pfiFileType,
      pfiFileRemark: data.pfiFileRemark,
      petPrisonerId: data.petPrisonerId,
      petTalkTime: data.petTalkTime,
      petTalkTimeLong: data.petTalkTimeLong,
      petTalkClassify: data.petTalkClassify,
      petTalkType: data.petTalkType,
      petTalkEffect: data.petTalkEffect,
      petEmotionEvaluate: data.petEmotionEvaluate,
      petDangerEvaluate: data.petDangerEvaluate,
      petDangerAction: '',
      petRemark: data.petRemark,
      file: data.file
    }
  });
}

export function getDepList(token, code) {
  console.log(token, code);
  return request({
    method: 'get',
    url: '/v1/educate/talk/deptList',
    headers: {
      token
    },
    params: {
      sdtOrgCode: code
    }
  });
}

export function getDeptDetails(token, deptId) {
  return request({
    method: 'get',
    url: `/v1/educate/talk/eduAll/${deptId}`,
    headers: {
      token
    },
    params: {
      deptId
    }
  });
}
//新增日志
export function addWorkDiary(token, dto) {
  return request({
    method: 'post',
    data: dto,
    url: 'v1/policeWorkLog/add',
    headers: {
      token
    }
  });
}
//查询日志
export function queryByContent(token, params) {
  return request({
    method: 'get',
    params: params,
    url: 'v1/policeWorkLog/queryByContent',
    headers: {
      token
    }
  });
}
//查询提交日志人数
export function queryByCount(token) {
  return request({
    method: 'get',
    url: 'v1/policeWorkLog/queryByCount',
    headers: {
      token
    }
  });
}

//根据日期查询释放罪犯
export function queryByRelease(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/prisonerRelease/queryByRelease',
    headers: {
      token
    }
  });
}

//根据日期查询释放罪犯人数
export function queryPrisonByCount(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/prisonerRelease/queryByCount',
    headers: {
      token
    }
  });
}

export function applyTalkHistoryList(
  token,
  pageSize,
  pageNum,
  deptId,
  petCreateTime
) {
  return request({
    method: 'get',
    url: '/v1/educate/talk/deptEduList',
    headers: {
      token
    },
    params: {
      deptId,
      petCreateTime,
      pageSize,
      pageNum
    }
  });
}

export function applyUserManual(token, search, type) {
  return request({
    method: 'get',
    url: type === 0 ? '/v1/BasicExplain/list' : '/v1/BasicExplain/selectBook',
    headers: {
      token
    },
    params: {
      search
    }
  });
}

export function appluEduTalkTypes(token, pdGroups, pdParentCode) {
  return request({
    method: 'get',
    url: '/v1/dict/diction/queryByGroup',
    headers: {
      token
    },
    params: {
      pdGroups,
      pdParentCode
    }
  });
}

export function applyRepaireList(token, bdId, pageNum, pageSize, _idx) {
  let urls = '';
  if (_idx === 0) {
    urls = '/v1/breakdownDeclare/list';
  } else if (_idx === 1) {
    urls = '/v1/breakdownDeclare/queryByMyDeclare';
  } else if (_idx === 2) {
    urls = '/v1/breakdownDeclare/queryByMyMaintain';
  } else {
    urls = '/v1/breakdownDeclare/queryByShelters';
  }
  return request({
    method: 'get',
    url: urls,
    headers: {
      token
    },
    params: {
      token,
      bdId,
      pageNum,
      pageSize
    }
  });
}

export function addRepaireHandle(token, dto) {
  return request({
    method: 'POST',
    url: '/v1/breakdownDeclare/add',
    headers: {
      token
    },
    data: dto
  });
}

export function applyCriminalInfo(token, code) {
  return request({
    method: 'POST',
    url: '/v1/prisonerInfo/recogniDetail',
    headers: {
      token
    },
    params: {
      code,
      type: 1
    }
  });
}
//根据日期查询个人考勤
export function queryPoliceList(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/attendance/record/list',
    headers: {
      token
    }
  });
}

//根据日期查询个人实绩考评
export function queryPoliceAppraisalList(token, params) {
  return request({
    method: 'get',
    params: params,
    url: '/v1/attendance/evaluation/list',
    headers: {
      token
    }
  });
}

//查询信件登记
export function queryMailRegisterList(token) {
  return request({
    method: 'get',
    url: '/v1/mailRegister/list',
    headers: {
      token
    }
  });
}
